package TankGame03;

import java.util.Vector;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class MyTank extends Tank {
    Shot shot = null;
    Vector<Shot> MyShots = new Vector<>();
    public MyTank(int x, int y, int direct) {
        super(x, y, direct);
    }

    public void fire() {
        if(MyShots.size() == 5){
            return;
        }

        switch (getDirect()) {
            case 0:
                    shot = new Shot(getX() + 20, getY(), 0);
                break;
            case 1:
                shot = new Shot(getX() + 60, getY() + 20, 1);
                break;
            case 2:
                shot = new Shot(getX() + 20, getY() + 60, 2);
                break;
            case 3:
                shot = new Shot(getX(), getY() + 20, 3);
                break;
        }
        //将子弹加入到我方子弹集合中
        MyShots.add(shot);
        //启动线程
        new Thread(shot).start();
    }

}
